import axios from '../config/axios'
import {getStore} from '../config/mUtils'

// export const getMsg = ()=>axios1('http://localhost/fumeng_test/api/my/getUserInfo.php',{
//     method:"POST",
//     headers:{
//         'Content-Type': 'application/x-www-form-urlencoded'
//     },
//     data:Qs.stringify({loginkey:'1146b7409e4d8d89f5449a7ed8f2fd02'})
    
// })

const BASE = 'https://www.bigzhuan.com/fumengAdmin/';//地址
// const BASE = 'http://bizhuan.qmhkids.com/bizhuan/';//测试地址
// const BASE = 'http://localhost/fumengAdmin/';//本地测试地址
// const BASE = 'http://guolinyu.com/fumengAdmin/';//本地测试地址

const GETCODE = BASE + 'api/sendcode.php';//获取验证码 参数 type='reg forget editphone' phone
const LOGIN = BASE + 'api/login.php';//登录接口 参数phone,pwd
const REGISTER = BASE + 'api/reg.php';//注册接口 参数：phone code pwd yqm source
const FORGET = BASE + 'api/forget.php';//忘记和修改密码 参数:loginkey oldcode newphone
const SETPHONE = BASE + 'api/editphone.php';//修改手机号 参数 
const INDEX = BASE + 'api/index.php';//首页接口
const PTLIST = BASE + 'api/ptlist.php';//平台列表
const CPLIST = BASE + 'api/cplist.php';//产品列表 参数 jine qixian ptid
const INVESTRECORD = BASE + 'api/my/tzlist.php';//投资记录 参数loginkey status1 2 3
const TRANSATION = BASE + 'api/my/jylist.php';//资金明细 参数 login status 1 2
const BINDACCOUNT = BASE + 'api/my/zhanghao.php';//绑定账号 参数 m name idcard bankId bankName bankNum bankPhone
const GETMONEY = BASE + 'api/my/tixian.php';//提现申请 参数 loginkey code money type（bank,alipay）
const GETMSG = BASE + 'api/gglist.php';//消息接口
const SKIP = BASE + 'skip.php';//记录跳转信息 参数 id loginkey
const SHAREINFO = BASE + 'api/my/yaoqing.php';//分享信息 参数 loginkey
const BACKPLAN = BASE + 'api/my/hklist.php';//回款计划 参数 loginkey start:2018-06-01 end:2018-06-01
const RELEASE = BASE + 'api/my/zhuanrang.php';//发布 
const DEBT = BASE + 'api/zrlist.php';//转让List
const NEWS = BASE + 'api/tzgl.php';;//比赚头条

// const WXINFO = 'http://bizhuan.qmhkids.com/bizhuan/api/wx.php'
const WXINFO = BASE + 'api/wx.php' //获取微信用户信息

/**
 * 微信分享接口
 */
const WXSHARE = BASE + 'ajax/wxshare.php';
/**
 * 活动接口
 */
const GETSOREC = BASE + 'api/huodong.php';//答题接口
/**
 * 图片地址
 */
const GETALLCP = BASE + 'api/allcplist.php';//所有产品

export const BASE_URL = 'http://bigzhuan.com';
export const IMG_URL = BASE_URL + '/assets/';

export const getNews = (page=1) => axios(NEWS,{
    page:page
})

export const getJiang = (m,openid) => axios(WXINFO,{
    m:m,
    openid:openid
})

//转让页面搜索和筛选功能
export const getDebtSearch = (pt_name) => axios(DEBT,{
    pt_name:pt_name
})

//转让信息list
export const getDebt = (page=1) => axios(DEBT,{
    page:page
})

//获取用户转让信息
export const myZR = (loginkey) => axios(RELEASE,{
    m:'myZR',
    loginkey:loginkey
})

//发布转让信息
export const toDebt = (pt_name,tztime,dqtime,tzmoney,zrmoney,loginkey) => axios(RELEASE,{
    m:'save',
    pt_name:pt_name,
    tztime:tztime,
    dqtime:dqtime,
    tzmoney:tzmoney,
    zrmoney:zrmoney,
    loginkey:loginkey
})

//获取微信用户信息
export const getWXInfo = (code) => axios(WXINFO,{
    m:'userinfo',
    code:code
})

//活动接口
export const getSorce = (name,phone,score) => axios(GETSOREC,{
    name:name,
    phone:phone,
    answer:score,
    m:'answer'
})

let loginkey = getStore('loginkey');
// export const getMsg = (loginkey)=>axios('http://localhost/fumeng_test/api/my/getUserInfo.php',{
//     loginkey:loginkey
// },"POST")

export const getWXSDK = (url) => axios(WXSHARE,{
    url:url
})
//获得所有产品
export const getAllcp = (ptlx=0,ptbj=0,lcType='') => axios(GETALLCP,{
    ptlx:ptlx,
    ptbj:ptbj,
    lc_type:lcType
})

export const getBackPlan = (loginkey,start,end,month) => axios(BACKPLAN,{
    loginkey:loginkey,
    start:start,
    end:end,
    month:month
})

//修改方案
export const changeHelperList = (money,time,pids) => axios(CPLIST,{
    jine:money,
    qixian:time,
    ptid:pids
})

//收益助手
export const getHelperList = (money,time) => axios(CPLIST,{
    jine:money,
    qixian:time
})

//分享信息
export const getShare = (loginkey) => axios(SHAREINFO,{
    loginkey:loginkey
})

//平台排序
export const getSort = (yearSort,timeSort,backSort) => axios(PTLIST,{
    m:'search',
    yearSort:yearSort,
    timeSort:timeSort,
    backSort:backSort
});

//平台筛选
export const getFilter = (lx,bj,nh,qx) => axios(PTLIST,{
    m:'search',
    lx:lx,
    nh:nh,
    bj:bj,
    qx:qx
});

//跳转
export const skip = (id,loginkey) => axios(SKIP,{
    id:id,
    loginkey:loginkey
});

//消息
export const getMsg = () => axios(GETMSG);

//消息详情
export const getMsgDetail = (id) => axios(GETMSG,{
    m:'gginfo',
    id:id
});

//平台详情
export const ptDetail = (id) => axios(PTLIST,{
    m:'ptinfo',
    id:id
});

//产品详情
export const cpDetail = (id) => axios(PTLIST,{
    m:'cpinfo',
    id:id
});

export const wxShare = () => axios(WXSHARE);
//搜索
export const getSearch = (keyword,lc_type)=> axios(PTLIST,{
    m:'search',
    keyword:keyword,
    lc_type:lc_type
})

//提现申请
export const getMoney = (loginkey,code,money,type) => axios(GETMONEY,{
    loginkey:loginkey,
    code:code,
    money:money,
    type:type
})

//变更支付宝
export const changeAlipay = (loginkey,alipayNum,nickName) => axios(BINDACCOUNT,{
    loginkey:loginkey,
    m:'alipay',
    alipayNum:alipayNum,
    nickName:nickName
})

//变更银行卡
export const changeBank = (loginkey,bankId,bankName,bankNum,bankPhone,bankNameZH) => axios(BINDACCOUNT,{
    loginkey:loginkey,
    m:'bank',
    bankId:bankId,
    bankName:bankName,
    bankNum:bankNum,
    bankPhone:bankPhone,
    bankNameZH:bankNameZH
})

//查看绑定信息
export const getBindInfo = (loginkey) => axios(BINDACCOUNT,{
    loginkey:loginkey,
    m:'info'
})

//绑定支付宝
export const bindAlipay = (loginkey,name,idcard,alipayNum,nickName) => axios(BINDACCOUNT,{
    loginkey:loginkey,
    m:'alipay',
    name:name,
    idcard:idcard,
    alipayNum:alipayNum,
    nickName:nickName
})

//绑定银行
export const bindBank = (loginkey,name,idcard,bankId,bankName,bankNum,bankPhone,bankNameZH) => axios(BINDACCOUNT,{
    loginkey:loginkey,
    m:'bank',
    name:name,
    idcard:idcard,
    bankId:bankId,
    bankName:bankName,
    bankNum:bankNum,
    bankPhone:bankPhone,
    bankNameZH:bankNameZH
})
//资金明细 返利
export const getTransation1 = (loginkey) => axios(TRANSATION,{
    loginkey:loginkey,
    status:1
})

//资金明细 提现
export const getTransation2 = (loginkey) => axios(TRANSATION,{
    loginkey:loginkey,
    status:2
})

//资金明细 全部
export const getTransation = (loginkey) => axios(TRANSATION,{
    loginkey:loginkey,
})

//投资记录 待确认
export const getInvestRecord1 = (loginkey) => axios(INVESTRECORD,{
    loginkey:loginkey,
    status:1
})
//投资记录 已投资
export const getInvestRecord2 = (loginkey) => axios(INVESTRECORD,{
    loginkey:loginkey,
    status:2
})
//投资记录 未投资
export const getInvestRecord3 = (loginkey) => axios(INVESTRECORD,{
    loginkey:loginkey,
    status:3
})

//平台列表
export const getPTList = () => axios(PTLIST);

//产品列表 
export const getCPList = (jine,qixian,ptid) => axios(CPLIST,{
    jine:jine,
    qixian:qixian,
    ptid:ptid
});

export let getIndex='';
//首页
if(getStore('loginkey')){
    getIndex = ()=>axios(INDEX,{
        loginkey:getStore('loginkey')
    });
}else{
    getIndex = ()=>axios(INDEX);
}

//获取验证码
export const getCode = (type,phone)=>axios(GETCODE,{
    type:type,
    phone:phone
})

//获取验证码 提现
export const getCodeTi = (type,phone,loginkey)=>axios(GETCODE,{
    type:type,
    phone:phone,
    loginkey:loginkey
})

//注册
export const register = (phone,pwd,code,yqm,source)=>axios(REGISTER,{
    phone:phone,
    pwd:pwd,
    code:code,
    yqm:yqm,
    source:source
})

//登录
export const login = (phone,pwd)=>axios(LOGIN,{
    phone:phone,
    pwd:pwd,
})

//忘记和修改密码
export const forget = (phone,code,pwd)=>axios(FORGET,{
    phone:phone,
    code:code,
    pwd:pwd,
})

//修改手机号step1
export const setPhone1 = (oldphone,oldcode)=>axios(SETPHONE,{
    m:'editpwd1',
    oldcode:oldcode,
    oldphone:oldphone,
})

//修改手机号step2
export const setPhone2 = (oldphone,newphone,newcode,valid)=>axios(SETPHONE,{
    m:'editpwd2',
    newcode:newcode,
    oldphone:oldphone,
    newphone:newphone,
    valid:valid
})

export const BANKS = {
    '中国工商银行':IMG_URL + 'gs.png',
    '招商银行':IMG_URL + 'zs.png',
    '中国农业银行':IMG_URL + 'ny.png',
    '中国建设银行':IMG_URL + 'js.png',
    '中国银行':IMG_URL + 'zg.png',
    '中国民生银行':IMG_URL + 'ms.png',
}

export const PLATNAMES = [
    "宜人贷",
    "陆金服",
    "人人贷",
    "拍拍贷",
    "微贷网",
    "团贷网",
    "点融网",
    "积木盒子",
    "投哪网",
    "有利网",
    "爱钱进",
    "翼龙贷",
    "麻袋财富",
    "51人品",
    "和信贷",
    "小赢网金",
    "搜易贷",
    "宜贷网",
    "开鑫贷",
    "向上金服",
    "PPmoney网贷",
    "理财农场",
    "你我贷",
    "博金贷",
    "银湖网",
    "友金服",
    "金投行",
    "杉易贷",
    "民贷天下",
    "信用宝",
    "道口贷",
    "海融易",
    "91旺财",
    "洋钱罐",
    "人人聚财",
    "金开贷",
    "石投金融",
    "鹏金所",
    "广州e贷",
    "e融所",
    "口袋理财",
    "首金网",
    "万盈金融",
    "红岭创投",
    "首E家",
    "珠宝贷",
    "奇乐融",
    "短融网",
    "e路同心",
    "东方汇",
    "合众e贷",
    "广信贷",
    "网利宝",
    "捞财宝",
    "嘉石榴",
    "广金金服",
    "生菜金融",
    "链链金融",
    "米庄理财",
    "惠投无忧"
]
